package net.guerlab.sdk.anubis;

import java.util.Arrays;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import net.guerlab.sdk.anubis.entity.ChainStoreAddInfo;
import net.guerlab.sdk.anubis.request.ChainStoreAddRequest;
import net.guerlab.sdk.anubis.request.ChainStoreQueryRequest;
import net.guerlab.sdk.anubis.response.ChainStoreAddResponse;
import net.guerlab.sdk.anubis.response.ChainStoreQueryResponse;

/**
 * 门店 demo
 * 
 * @author guer
 *
 */
public class ChainStoreDemo {

    private static final Logger LOGGER = LoggerFactory.getLogger(ChainStoreDemo.class);

    /**
     * 添加门店
     */
    @Test
    public void add() {
        ChainStoreAddRequest request = new ChainStoreAddRequest();

        ChainStoreAddInfo chainStoreAddInfo = new ChainStoreAddInfo();
        chainStoreAddInfo.setName("web-base-test");
        chainStoreAddInfo.setContactPhone("13558911947");
        chainStoreAddInfo.setAddress("300弄亚都国际名园5号楼2003室");
        chainStoreAddInfo.setLongitude("121.3718891000");
        chainStoreAddInfo.setLatitude("31.2306375000");
        chainStoreAddInfo.setPositionSource(3);
        chainStoreAddInfo.setServiceCode(1);

        request.setChainStore(chainStoreAddInfo);

        ChainStoreAddResponse response = DemoConfig.CLIENT.execute(request);

        LOGGER.debug("chain store add result : {}", response.getData());
    }

    /**
     * 查询门店
     */
    @Test
    public void query() {
        ChainStoreQueryRequest request = new ChainStoreQueryRequest();

        request.setChainStoreNames(Arrays.asList("饿了么"));

        ChainStoreQueryResponse response = DemoConfig.CLIENT.execute(request);

        LOGGER.debug("chain store list : {}", response.getData());
    }
}
